package de.openkanban.client.ui.presenter;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.smartgwt.client.util.SC;

import de.openkanban.client.ui.board.ActivityView;
import de.openkanban.client.util.RootPanel;
import de.openkanban.shared.dto.KanbanDto;

public class MoveKanbanToActivityRequestCallback implements RequestCallback {

	private ActivityView activityView;

	public MoveKanbanToActivityRequestCallback(ActivityView activityView) {
		this.activityView = activityView;
	}

	@Override
	public void onResponseReceived(Request request, Response response) {
		KanbanDto kanbanDto = new KanbanDto(response.getText());

		if (kanbanDto.getFehlerKz() > 0) {
			SC.say(kanbanDto.getFehlerText());
		} else {
			activityView.createKanbanView(kanbanDto);
			RootPanel.main.getFooter().updateBoardHistoryData();

			// TODO kanban updaten und pullable false setzen

		}
	}

	@Override
	public void onError(Request request, Throwable exception) {

	}

}
